home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / confaccess / confaccess.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.3 KB  |  118 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "dh0:code/code20/defines.h"
  6. #include "work:romconf/doorheader.h"
  7. struct Commands cmds;
  8. struct User U;
  9. void end();
  10. void sr();
  11. #define sm sendmessage
  12. #define gu getuserstring
  13.  
  14. int node;
  15. main(int argc, char *argv[])
  16. {
  17.    char conf[200];
  18.    char cfg[100];
  19.    char Udat[100];
  20.    char temp[200];
  21.    char PutPt[200];
  22.    int num=0;
  23.    int cn;
  24.    FILE *fi,*fo;
  25.    if(argc!=2)
  26.    {
  27.      printf("\n");
  28.      printf("Conference Access v1.0 written by Joseph Hodge\n");
  29.      printf("This is an AmiExpress 1.1w+ XIM\n");
  30.      printf("\n\n");
  31.      exit(0);
  32.    }
  33.    node= argv[1][0]-'0';
  34.    Register(argv[1][0]-'0');
  35.    gu(conf,BB_CONFNAME);
  36.    gu(temp,BB_LOCAL);
  37.    sprintf(cfg,"%sconfig%d",temp,node);
  38.    fi=fopen(cfg,"rb");
  39.    if(fi==NULL)
  40.    {
  41.      sm("Error, can't locate config file",1);
  42.  
  43.      ShutDown();
  44.      end();
  45.    }
  46.    fread((APTR)&cmds,sizeof(struct Commands),1,fi);
  47.    fclose(fi);
  48.    
  49.    cn=0;
  50.    strupr(conf);
  51.    sr(conf);
  52.    while(cn<9)
  53.    {
  54.      strupr(&cmds.ConfName[cn]);
  55.      sr(&cmds.ConfName[cn]);
  56.      if(!strcmp(conf,&cmds.ConfName[cn]))
  57.       break;
  58.      cn++;
  59.    }
  60.    if(cn==9)
  61.    {
  62.      sm("Can't locate conference",1);
  63.      ShutDown();
  64.      end();
  65.    }
  66.  
  67.    sprintf(Udat,"%sUser.Data",temp);
  68.    fi=fopen(Udat,"rb");
  69.    if(fi==NULL)
  70.    {
  71.      sm("Can't locate User data file",1);
  72.      ShutDown();
  73.      end();
  74.    }
  75.    sprintf(PutPt,"%sNode%d/Work/PutPt.txt",temp,node);
  76.    fo=fopen(PutPt,"w");
  77.    if(fo==NULL)
  78.    {
  79.       fclose(fi);
  80.       sm("Error, can't create work file",1);
  81.       ShutDown();
  82.       end();
  83.    }
  84.    fprintf(fo,"\n");
  85.    fprintf(fo,"                         Conference Access List\n");
  86.    fprintf(fo,"\n");
  87.    while(fread((APTR)&U,sizeof(struct User),1,fi)!=NULL)
  88.    {
  89.      if(U.Conference_Access[cn]=='X')
  90.      {
  91.        fprintf(fo,"     [%3d] %-20.20s  -=+=- %-20.20s\n",num,U.Name,U.Location); num++;
  92.      }
  93.    }
  94.  
  95.    fclose(fo);
  96.    fclose(fi);
  97.    sprintf(PutPt,"%sNode%d/Work/PutPt",temp,node);
  98.    showgfile(PutPt);
  99.    unlink(PutPt);
  100.    ShutDown();
  101.    end();
  102. }
  103.  
  104. void end()
  105. {
  106.   exit(0);
  107. }
  108. void sr(char *str)
  109. {
  110.   register int i;
  111.   i=strlen(str)-1;
  112.   while(i>-1)
  113.   {
  114.     if(*(str+i)<=32) *(str+i)='\0'; else break;
  115.     i--;
  116.   }
  117. }
  118.